package com.tanguy.user.ui.trip.activity

import android.app.Activity
import android.content.Intent
import android.widget.TextView
import com.tanguy.user.Const
import com.tanguy.user.R
import com.tanguy.user.bean.orde.BaseOrderBean
import com.tanguy.user.bean.orde.StationOrderBean
import com.tanguy.user.ui.trip.choice.activity.ChoiceFlightActivity
import com.tanguy.user.utlis.extend.click
import kotlinx.android.synthetic.main.view_stub_receive_plane.*
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivityForResult

/**
 * Created by dab on 2017/10/24 0024 17:20
 * 接机的界面
 */
class ReceivePlaneActivity : BasePickerActivity() {
    override fun getOrderBean(): BaseOrderBean = StationOrderBean()
    override fun onCarTypeChanged(position: Int) {


    }

    override fun getSpecialViewRes(): Int = R.layout.view_stub_receive_plane

    override val type: Int = 1


    private val mTvFlightNumber by lazy { find<TextView>(R.id.tv_flight_number) }


    override fun initView() {
        super.initView()
        click(mTvFlightNumber) { startActivityForResult<ChoiceFlightActivity>(Const.RequestCode.FLIGHT_NUMBER) }
        click(tv_time) {

        }

    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (data == null) return
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == Const.RequestCode.FLIGHT_NUMBER) {
                val name = data.getStringExtra("name")
                val flight_number = data.getStringExtra("flight_number")
                val time = data.getStringExtra("time")
                tv_flight_number.text = flight_number
                tv_time.text = time
                et_start.setText(name)

            }
        }
    }

}